#include "MoveTreeNode.h"

using namespace Rorn::Chess::TheCorruptRook;

MoveTreeNode::MoveTreeNode(const Position& position, Player::Type player)
	: position_(position), player_(player), depth_(0), startSquare_(-1,-1), endSquare_(-1,-1)
{

}

MoveTreeNode::MoveTreeNode(const Position& startPosition, Player::Type player, int depth, const Square& startSquare, const Square& endSquare)
	: position_(startPosition), player_(player), depth_(depth), startSquare_(startSquare), endSquare_(endSquare)
{
	position_.MovePiece(Player::GetOpposite(player), startSquare, endSquare);
}

MoveTreeNode::~MoveTreeNode()
{
}

void MoveTreeNode::Evaluate(int maxDepth)
{
	position_.GetLegalMoves(player_, moves_, depth_ + 1);
	if(depth_ < maxDepth)
	{
		for(std::vector<MoveTreeNode>::iterator moveIter = moves_.begin() ; moveIter != moves_.end() ; ++moveIter)
		{
			moveIter->Evaluate(maxDepth);
		}
	}
}